package com.bs.sc.base.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import lombok.Data;

@Data
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public class BaseEntity {

	@Id
	@GenericGenerator(name = "jpa-uuid", strategy = "uuid")
	@GeneratedValue(generator = "jpa-uuid")
	@Column(name = "id", length = 64)
	private String id;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_date")
	@CreatedDate
	private Date createDate;

	@Column(name = "create_user", length = 64)
	@CreatedBy
	private String createUser;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "update_date")
	@LastModifiedDate
	private Date updateDate;

	@Column(name = "update_user", length = 64)
	@LastModifiedBy
	private String updateUser;

}
